﻿using log4net.Core;
using SvGame.Objects;
using System.Numerics;
using UtilLib;

namespace SvGame.Logic;

public enum EPowerType
{
    Attack = 1, // 命中
    Dodge = 2, // 闪避
    Parry = 3, // 招架
}

public static partial class GameLogic
{
    /// <summary>
    /// 获取power
    /// </summary>
    /// <param name="me"></param>
    public static long GetPower(this IRole me, EPowerType powerType, out string skillId)
    {
        skillId = "";
        if (!me.Living)
        {
            return 0;
        }
        EUsageType usage = powerType switch
        {
            EPowerType.Attack => me.Comb.ActEquipUsageType,
            EPowerType.Dodge => EUsageType.基本轻功,
            EPowerType.Parry => EUsageType.拆招卸力,
            _ => EUsageType.扑击格斗,
        };
        // 获取有效等级
        me.UsageGet(usage, out skillId, out var usageLevel);

        // todo GetPower 临时
        //level += ob->query_temp("apply/attack");

        // 如果等级为0
        if (usageLevel <= 0)
        {
            return me.Exp / 2;
        }

        long power = 0;
        power += usageLevel * usageLevel * usageLevel;

        power *= me.StatusCur.Sen;
        power /= me.StatusMax.Sen;

        power += me.Exp;

        return power;
    }
    // ap
    public static long GetAttackPower(this IRole me, out string skillId) 
        => me.GetPower(EPowerType.Attack, out skillId);
    // dp
    public static long GetDodgePower(this IRole me, out string skillId) 
        => me.GetPower(EPowerType.Dodge, out skillId);
    // pp
    public static long GetParryPower(this IRole me, out string skillId) 
        => me.GetPower(EPowerType.Parry, out skillId);

}
